package com.logos.cartoon.utils;

import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import org.springframework.stereotype.Component;

@Component
public class ChatReqUtil {

    public static final String chatUrl = "http://localhost:11434/api/chat";
    public String createJson(String model,String content) {
        Gson gson = new Gson();
        JsonObject message = new JsonObject();
        message.addProperty("role", "user");
        message.addProperty("content", content);

        JsonArray messages = new JsonArray();
        messages.add(message);

        JsonObject options = new JsonObject();
        options.addProperty("temperature", 0.7);
        options.addProperty("max_tokens", 100);

        JsonObject json = new JsonObject();
        json.addProperty("model", model);
        json.add("messages", messages);
        json.addProperty("stream", false);
        json.add("options", options);

        return gson.toJson(json);
    }
}
